<?

class CTableGenerator
{
	var $style = "";			// style attribute of the table
	var $widths;				// widths of columns
	
	var $cl_tr_bg_color_0 = "#FFFFFF";
	var $cl_tr_bg_color_1 = "#F5F5F5";
	
	var $row_index = 0;
	
	
	function CTableGenerator()
	{
	}
	
	function PrintHeader($items)
	{
		echo '<table border="1" cellspacing="0" cellpadding="0" class="box_table" style="'.$this->style.'" >'."\n";
		echo "<tr>\n";
		$i = 0;
		foreach ($items as $item)
		{
			echo "\t".'<td'.$this->GetSmartWidth($i).' class="heading_box">'.$item.'</td>'."\n";
			$i++;
		}
		echo "</tr>\n";
	}

	function PrintRow($items, $tr_ext="")
	{
		$cl = ($this->row_index % 2 == 0 ? $this->cl_tr_bg_color_0 : $this->cl_tr_bg_color_1);
		echo "<tr bgcolor=\"$cl\"$tr_ext>\n";
		$i = 0;
		foreach ($items as $item)
		{
			echo "\t".'<td'.$this->GetSmartWidth($i).' class="box_td_text">'.$item.'</td>'."\n";
			$i++;
		}
		echo "</tr>\n";
		$this->row_index++;
	}

	function PrintFooter()
	{
		echo "</table>\n";
	}
	
	
	function GetSmartWidth($col_index)
	{
		if ($this->row_index != 0) return "";
		
		$w = @$this->widths[$col_index];
		if ($w != "") $w = ' width="'.$w.'"';
		return $w;
	}
}

?>
